<!DOCTYPE html>
<html>
<head>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes"/>
    <meta charset="UTF-8">
    <title>NGA bot酱</title>
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/queryString.js"></script>
    <script type="text/javascript">

    </script>
    <style type="text/css">
        .err {
            color: red;
        }

        input {
            width: 100px;
        }

        select {
            width: 100px;
        }
    </style>

    <style type="text/css">
        .err {
            color: red;
        }

        input {
            width: 70%;
        }

        .customers {
            font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
            width: 100%;
            border-collapse: collapse;

        }

        .customers td, #customers th {
            font-size: 1em;
            border: 1px solid #98bf21;
            padding: 3px 7px 2px 7px;
        }

        .customers th {
            font-size: 1.1em;
            text-align: left;
            padding-top: 5px;
            padding-bottom: 4px;
            background-color: #A7C942;
            color: #ffffff;
        }

        .customers tr.alt td {
            color: #000000;
            background-color: #EAF2D3;
        }
    </style>
</head>
<body>
<div id="app">
    <table class="customers">
        <tr>
            <th>配置</th>
            <th>选项</th>
        </tr>
        <tr class="alt">
            <td>账号</td>
            <td>
                <select v-model="repostData.cookie">
                    <option v-for="item in config.cookie">{{item}}</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>版面</td>
            <td>
                <select v-model="repostData.fid">
                    <option v-for="item in config.fid">{{item}}</option>
                </select>
            </td>
        </tr>
        <tr class="alt">
            <td>主题</td>
            <td>
                <select v-model="repostData.tid">
                    <option v-for="item in config.tid">{{item}}</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <button @click="testMode()">测试模式</button>&nbsp;
            </td>
            <td>
                <button @click="getImoko()">薯妈</button>&nbsp;
            </td>
        </tr>
    </table>
    <br><br>
    <!--微博-->
    <table class="customers" v-for="item in weibo">
        <tr class="alt">
            <td style="width: 10%">发布时间
            </td>
            <td>{{item.createdStr}}</td>
        </tr>
        <tr>
            <td>标题
                <button @click="repost('new',item.id)">转发主题</button>
            </td>
            <td><input type="text" :value="item.title"></td>
        </tr>
        <tr>
            <td>正文
                <button @click="repost('reply',item.id)">转发回复</button>
            </td>
            <td><textarea style="width: 90%" rows="10">{{item.bbsCode}}</textarea></td>
        </tr>

    </table>

</div>
</body>
<script>
    const app = new Vue({
        el: "#app",
        data: {
            config: {
                cookie: {},
                fid: {},
                tid: {},
            },
            repostData: {
                action: "",
                cardId: "",
                fid: "",
                cookie: "",
                tid: "",
            },
            weibo: {},
        },
        methods: {
            getConfig() {
                get("config/get", null, function (res) {
                    console.log(res.data);
                    _this.config = res.data;
                    _this.repostData.cookie = res.data.cookie[0]
                    _this.repostData.fid = res.data.fid[0]
                    _this.repostData.tid = res.data.tid[0]
                })
            },

            getWeibo() {
                get("wb/gf", null, function (res) {
                    console.log(res.data);
                    _this.weibo = res.data;
                })
            },
            getImoko() {
                get("wb/imoko", null, function (res) {
                    console.log(res.data);
                    _this.weibo = res.data;
                })
            },

            repost(action, cardId) {
                this.repostData.action = action;
                this.repostData.cardId = cardId;
                get("wb/repost", this.repostData, function (res) {
                    console.log(res.data);
                    if (res.data.includes("http")) {
                        window.open(res.data);
                    } else {
                        alert(res.data)
                    }
                })
            },


            testMode() {
                get("wb/testMode", null, function (res) {
                    alert(res.data)
                })

            }
        },
        created() {
            this.getConfig();
            this.getWeibo();
        },
    });
    const _this = app;
</script>
</html>

